from flask import Flask,request
from flask import render_template


app = Flask(__name__)

@app.route('/',methods=['GET'])
def hello_world():
    return render_template('hello.html')


@app.route('/index',methods=['GET'])
def fullname():
    return render_template('index.html')

@app.route('/fullname',methods=['POST', 'GET'])
def fullname_result():
    py_firstname = request.form['firstname']
    py_lastname = request.form['lastname']
    py_fullname = py_firstname.title()+' '+py_lastname.title()
    return render_template('fullname_result.html', fullname = py_fullname)

@app.route('/letter',methods=['GET'])
def letter():
    return render_template('word.html')


@app.route('/py_letter',methods=['POST', 'GET'])
def letter_result():
    py_word = request.form['word']
    py_vowels = request.form['vowels']
    py_letter = set(request.form['word']) & set(request.form['vowels'])
    py_letter = {}
    for i in py_word:
        if i in py_vowels:
            py_letter.setdefault(i, 0)
            py_letter[i] += 1
    return render_template('word_result.html',letter=py_letter)



if __name__ == '__main__':
    app.run(host='127.0.0.1',port=5000,debug=True)